#pragma once

#include "kernel/agv/i_agv_command.h"
#include "kernel/interfaces/ILogger.h"
#include <memory>

namespace application {
namespace simulation {

class SimulationEngine;

/**
 * @brief 仿真AGV命令适配器
 * @details 实现 IAgvCommand 接口，将命令转换为仿真事件
 */
class SimAgvCommand : public kernel::agv::IAgvCommand {
public:
    explicit SimAgvCommand(
        int agvNumber,
        SimulationEngine* engine,
        std::shared_ptr<kernel::ILogger> logger
    );

    ~SimAgvCommand() override = default;

    // ==================== IAgvCommand 接口实现 ====================

    kernel::Result<void> moveToStationList(
        int agvNumber,
        const std::vector<std::string>& stations,
        const std::string& operation = ""
    ) override;

    kernel::Result<void> moveToStation(
        int agvNumber,
        const std::string& sourceId,
        const std::string& targetId
    ) override;

    kernel::Result<void> cancelTask(int agvNumber) override;

    kernel::Result<void> pauseTask(int agvNumber) override;

    kernel::Result<void> resumeTask(int agvNumber) override;

    kernel::Result<void> controlJack(int agvNumber, bool raise) override;

    kernel::Result<void> startCharging(int agvNumber, const std::string& chargePoint) override;

    kernel::Result<void> stopCharging(int agvNumber) override;

    kernel::Result<void> controlDoor(int agvNumber, int doorId, bool open) override;

    kernel::Result<void> switchMap(int agvNumber, const std::string& mapName, const std::string& switchPoint) override;

    kernel::Result<void> requestCurrentMap(int agvNumber) override;

private:
    int m_agvNumber;
    SimulationEngine* m_engine;
    std::shared_ptr<kernel::ILogger> m_logger;
};

} // namespace simulation
} // namespace application
